

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>

    <script src="http://g.tbcdn.cn/mtb/lib-flexible/0.3.4/??flexible_css.js,flexible.js"></script>
    <link rel="stylesheet" href="{{ADMIN_PATH}}css/demo.css" type="text/css" />
    <script src="{{ADMIN_PATH}}jquery/dist/jquery.js"></script>
    <script src="{{ADMIN_PATH}}layui/layuiadmin/layui/layui.js"></script>
    <script src="{{ADMIN_PATH}}js/admin.common.js"></script>
    <script type="text/javascript" src="{{ADMIN_PATH}}js/awardRotate.js"></script>
    <script src="{{ADMIN_PATH}}layui/layuiadmin/layui/layui.js"></script>
    <script src="{{ADMIN_PATH}}js/admin.common.js"></script>
    <style>

    </style>
    <script type="text/javascript">

        var gd;
        function autoScroll(){
            $("#gwgdson").animate({
                marginTop : "-0.8rem"
            },500,function(){
                $(this).css({marginTop : "0px"}).find("ul:first").appendTo(this);
            });
        }

        var last_num={{$last_num}};
        $(function (){

//	gd = setInterval('autoScroll()',2000);
//    $("#gwgd ul").hover(function(){
//        clearInterval(gd);
//    },function(){
//        gd = setInterval("autoScroll()",2000);
//    })

            var rotateTimeOut = function (){
                $('#rotate').rotate({
                    angle:0,
                    animateTo:2160,
                    duration:8000,
                    callback:function (){
                        alert('网络超时，请检查您的网络设置！');
                    }
                });
            };
            var bRotate = false;

            var rotateFn = function (awards, angles, txt){
                bRotate = !bRotate;
                $('#rotate').stopRotate();
                $('#rotate').rotate({
                    angle:0,
                    animateTo:angles+1800,
                    duration:8000,
                    callback:function (){

                        //添加中奖
                        jQuery.ajax({url: '{{url('admin/ordersys/luckdraw/add_awards')}}',
                                type: 'POST',
                                data:{d_id:{{$info->id}},awaer:awards},
                            async: false,
                            dataType: 'json',
                            success: function(data) {
                            if(data.status==200){
                               // ui.success(txt);
                                layer.msg(txt);
                                return false;
                            }else{
                                layer.msg(data.message);
                               // ui.error(data.msg);
                            }
                        },
                        error:function(){
                           // ui.error("异常");
                            return false;
                        }
                    });





                        bRotate = !bRotate;
                    }
                })
            };

            $('.pointer').click(function (){

                var start = {{intval($info->start_time)}};
                var end = {{intval($info->end_time)}};
                var now = {{time()}};
                if(start>0 && now<start){
                    layer.msg('抽奖时间还没到，请稍等');
                    return false;
                }
                if(end>0 && now>end){
                    layer.msg('抽奖时间结束，你来晚了');
                    return false;
                }



                {{--var flag_four=false;--}}

                {{--jQuery.ajax({url: '{{url('admin/ordersys/luckdraw/show_four_one')}}',--}}
                        {{--type: 'POST',--}}
                        {{--data:{d_id:{{$info->id}}},--}}
                    {{--async: false,--}}
                    {{--dataType: 'json',--}}
                    {{--success: function(data) {--}}
                    {{--if(data.status==1){--}}
                    {{--//    ui.error(data.info);--}}
                        {{--flag_four=true;--}}
                        {{--return false;--}}
                    {{--}--}}
                {{--},--}}
                {{--error:function(){--}}
                 {{--//   ui.error("异常");--}}
                    {{--return false;--}}
                {{--}--}}
            {{--});--}}
                {{--if(flag_four){--}}
                    {{--return false;--}}
                {{--}--}}
                if(last_num<=0){
                   // ui.error("您总次数已用完");
                    return false;
                }

                last_num=last_num-1;





                if(bRotate)
                    return;

                var items = $.ajax({
                        url: '{{url('admin/ordersys/luckdraw/testmy')}}',
                        data:{id:{{$info->id}}},
                    async: false,
            }).responseText;
                var item=parseInt(items);
                //item = 2;
                switch (item) {
                    case 0:
                        //var angle = [26, 88, 137, 185, 235, 287, 337];
                        rotateFn(0, 337,'{{$rmsg[0]}}');
                        break;
                    case 1:
                        //var angle = [88, 137, 185, 235, 287];
                        rotateFn(1, 26, '{{$rmsg[1]}}');
                        break;
                    case 2:
                        //var angle = [137, 185, 235, 287];
                        rotateFn(2, 287, '{{$rmsg[2]}}');
                        break;
                    case 3:
                        //var angle = [137, 185, 235, 287];
                        rotateFn(3, 185, '{{$rmsg[3]}}');
                        break;
                    case 4:
                        //var angle = [185, 235, 287];
                        rotateFn(4, 88, '{{$rmsg[4]}}');
                        break;
                    case 5:
                        //var angle = [185, 235, 287];
                        rotateFn(5, 137, '{{$rmsg[5]}}');
                        break;
                    case 6:
                        //var angle = [235, 287];
                        rotateFn(6, 235,'{{$rmsg[6]}}');
                        break;
                    case 7:
                        //var angle = [287];
                        rotateFn(7, 337,'{{$rmsg[0]}}');
                        break;
                }
                $("#last_num").html(last_num);
                console.log(item);
            });
        });
        function rnd(n, m){
            return Math.floor(Math.random()*(m-n+1)+n)
        }
    </script>

</head>
<body>
<div class="g-wrap">

    <div class="turntable-bg">
        <!--<div class="mask"><img src="__MSTATIC__/images/award_01.png"/></div>-->
        <div class="pointer"><img src="{{ADMIN_PATH}}images/pointer.png" alt="pointer"/></div>
        <div class="rotate" ><img id="rotate" src="{{ADMIN_PATH}}images/turntable2.png" alt="turntable"/></div>
    </div>
    <?php
    $now_time=time();
    ?>

    <?php if($now_time<$info->start_time){ ?>

    <div class="g-cjcs font18">活动还未开始</div>
    <div class="g-cjcs2">
        <p>开始时间：{{date("Y-m-d H:i",$info->start_time)}}</p>
        <p>结束时间：{{date("Y-m-d H:i",$info->end_time)}}</p>
    </div>
    <?php   }else if($now_time>$info->end_time){  ?>
    <div class="g-cjcs font18">
        活动已结束您来晚了<br>
        <!--                <span>{$info.start_date|date='Y-m-d H:i',###}-{$info.end_date|date='Y-m-d H:i',###}</span>-->
    </div>
    <?php  }else{  ?>
    <div class="g-cjcs font18">您还有<span class="g-cjcolor" id="last_num">{{$last_num}}</span>次抽奖机会</div>
    <?php } ?>

    <div class="g_bt" style="top: 3.2rem;">
        <button class="g_btn font18 show_award"  type="button" >中奖情况</button>
    </div>

</div>
<div class="weui_dialog_alert" id="dialog3" style="display:none"></div>


<script>
    layui.use(['element', 'form'], function () {
        var $ = layui.jquery
    , form = layui.form
        ;
        $(".show_award").bind("click", function () {


            var index = layer.open({
                type: 2
                , title: '我的获取奖日志'
                , content: '{{url('admin/ordersys/luckdraw/show_award')}}'
                , area: ['80%', '580px'] //宽高
                , maxmin: true
                , scrollbar: false
                , end: function (index, layero) {
                    //关闭弹窗后的事件
                }
            });
        });
    });
</script>
</body>
</html>
